package com.example.venadaoa.net;

import android.content.Context;
import android.graphics.Bitmap;

import com.example.venadaoa.datamanager.ServerResult;
import com.example.venadaoa.datamanager.UserInfo;
import com.example.venadaoa.tool.Constants;
import com.example.venadaoa.tool.PreferenceUitl;

import org.apache.http.message.BasicNameValuePair;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by weng on 2017/7/11.
 */

public class Api {

    public static void getLogin(Context context, String username,String password,String registrationid,Class cls, NetUtils.NetCallBack<ServerResult> netCallBack) {
        Map map = new HashMap();
        map.put("username", username);
        map.put("password",password);
        map.put("registrationid",registrationid);

        NetUtils.stringPost(context, URLS.getLogin(), map,"登录服务器中...", netCallBack,cls);
    }

    public static void getLoginOut(Context context, Class cls, NetUtils.NetCallBack<ServerResult> netCallBack)
    {
        Map map = new HashMap();
        map.put("userId", UserInfo.getUserInfor(context).getUserObject().getId());
        NetUtils.stringPost(context, URLS.getLoginOut(), map,"退出登陆中...", netCallBack,cls);
    }


    public static void getSystemInfo(Context context, Class cls, NetUtils.NetCallBack<ServerResult> netCallBack) {
        NetUtils.stringPost(context, URLS.getSystemInfo(), null,null, netCallBack,cls);
    }

    public static void getUserHead(Context context,  NetUtils.NetCallBack<Bitmap> netCallBack)
    {
        NetUtils.imageGet(context, null,URLS.getPhoto(),null, netCallBack);
    }



    public static void uploadUserHead(Context context,String path,Class cls,NetUtils.NetCallBack<ServerResult> netCallBack)
    {
        NetUtils.postPhoto(context,URLS.upLoadPhoto(),path,null,netCallBack,cls);
    }

    public static void getModifyPW(Context context, Map<String, String> params, Class cls, NetUtils.NetCallBack<ServerResult> netCallBack) {
        NetUtils.stringPost(context, URLS.getModifyPW(), null, "修改中...", netCallBack, cls);
    }

    public static void getUpdateUserInfo(Context context, Map<String, String> params, Class cls, NetUtils.NetCallBack<ServerResult> netCallBack) {
        NetUtils.stringPost(context, URLS.getUpdateUserInfo(), null, "修改中...", netCallBack, cls);
    }
    public static void getOtherPhoto(Context context, Map<String, String> params, NetUtils.NetCallBack<Bitmap> netCallBack) {
        NetUtils.imageGet(context, params,URLS.getOtherPhoto(), null, netCallBack);
    }


    public static void getNoticeList(Context context, String type,String page, Class cls, NetUtils.NetCallBack<ServerResult> netCallBack)
    {
        String url =URLS.getNoticeList()+"?type="+type+"&currentPage="+page;
        NetUtils.stringGet(context, url, "获取中...", netCallBack,cls);
    }

}
